import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

/**
 设备运行管理-运行记录接口
 **/
// 查询运行记录接口
export const queryRunRecord = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqp/runRecord/queryList", {
    data
  });
};
// 新增/修改运行记录接口
export const addRunRecord = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqp/runRecord/create", {
    data
  });
};
// 删除运行记录接口
export const deleteRunRecord = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqp/runRecord/delete", {
    data
  });
};
// 获取运行记录详情
export const getRunRecord = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqp/runRecord/queryListByEqpId", {
    data
  });
};
// 根据条件查询设备列表
export const getEquipSelect = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/publish/equipment/queryEqpList", {
    data
  });
};
// 设备属性-查询设备状态和时间
export const getEquipStatusTime = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentAttribute/queryStatusTime", {
    data
  });
};
// 运行台账-巡检任务接口
export const getInspectTaskList = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inspectTask/queryRecordListPage", {
    data
  });
};
// 运行台账-保养任务接口
export const getEpmTaskList = (data?: object) => {
  return http.request("post", "/pms/publish/queryJobsByEqpId", {
    data
  });
};
// 运行台账-异常点检接口
export const getExceptionTaskList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/pointCheckTask/pagePointCheckTask`, {
    data
  });
};
/**
 设备运行管理-状态原因接口
 **/
// 查询状态原因接口
export const queryRunStatusReason = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqp/downCause/queryList", {
    data
  });
};
// 新增/修改状态原因接口
export const addRunStatusReason = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqp/downCause/create", {
    data
  });
};
// 删除状态原因接口
export const deleteRunStatusReason = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqp/downCause/delete", {
    data
  });
};
// 状态原因下拉列表
export const getRunStatusReasonSelect = (data?: object) => {
  return http.request<Array<any>>("post", "/digitaltwins/api/v1/eqp/downCause/queryOptions", {
    data
  });
};
/**
 设备运行管理-操作计划接口
 **/
// 查询操作计划接口
export const queryOperatePlan = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqp/runRecord/queryPlanList", {
    data
  });
};
// 新增/修改操作计划接口
export const addRunOperatePlan = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqp/runRecord/createPlan", {
    data
  });
};
// 获取单条操作计划接口
export const getRunOperatePlan = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/eqp/runRecord/getRecord/${
    data
  }`);
};
// 确认操作计划
export const submitPlanAck = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqp/runRecord/planAck", {
    data
  });
};
// 备件出库-查询设备出库记录
export const getSparePartsOutByEqpId = (data) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/queryListByEqpId", {
    data
  });
};
// 设备运行管理-获取运行状态数量
export const queryEquipmentStatusNum = (data) => {
  return http.request("post", "/digitaltwins/api/v1/equipment/queryEquipmentStatusNum", {
    data
  });
};
// 设备运行管理记录-获取最新的一条记录
export const getRunRecordNew = (data) => {
  return http.request("post", `/digitaltwins/api/v1/eqp/runRecord/getByCreateId/${data}`);
};
